---
title: Benefit-payment stop processing
summary: Stops remaining scheduled benefit payments on a claim when a payment has been released.
status: draft
owner: SAIF Documentation Generator
last_reviewed: 2026-08-21
library: SAIF.Business.Claim
reference_type: embedded
operation_id: benefit-payment-stop
trigger: Caller invokes ProcessBenefitPayment(claimId, callingApplication[, callingFunction])
---

# Benefit-payment stop processing

Stops payments on active benefit schedules for a claim, either recording that a scheduled payment was released or deleting the payment row entirely, depending on whether a released scheduled payment exists.

| Field | Value |
| --- | --- |
| **Operation ID** | benefit-payment-stop |
| **Trigger** | Caller invokes `ProcessBenefitPayment(claimId, callingApplication[, callingFunction])` |
| **Inputs** | ClaimID, CallingApplication, CallingFunction (optional) |
| **Outputs** | Updated or deleted schedule/payment rows; `StopStatus`; boolean success |
| **Primary components** | `clsActiveBenefitSchedule.ProcessBenefitPayment` |
| **Entry point** | SAIF.Business.Claim/clsActiveBenefitSchedule.vb |

## Steps

1. Retrieve active benefit schedules for the claim where `REMAINING_PAYMENT_COUNT > 0` ([SQL-011](../sql/SQL-011.md), [CL_BENEFIT_SCHEDULE](../database-tables.md#cl_benefit_schedule)).
2. For each schedule row, retrieve the associated benefit payment ([SQL-012](../sql/SQL-012.md), [CL_BENEFIT_PAYMENT](../database-tables.md#cl_benefit_payment)).
3. Call `ClaimServices.hasReleasedScheduledPayment(...)` (external `SAIF.Business` package) to determine whether a released scheduled payment exists.**
   - If a released payment exists: execute the update path.
     - Execute `UpdateSchedSQL`, setting `RemainingPaymentCount = 1` ([SQL-039](../sql/SQL-039.md), [CL_BENEFIT_PAYMENT](../database-tables.md#cl_benefit_payment)).
     - If `RowsAffected = 0`: add error `#PAYUPD#` ([BR-009](../business-rules.md#br-009-benefit-schedule-update-must-affect-a-row)) and return `False`.
     - Otherwise: record `StopStatus.Released`.
   - Otherwise (no released payment): execute the delete path.
     - Execute `DeletePaymentSQL`, cascading-deleting the schedule/payment row ([SQL-054](../sql/SQL-054.md), [CL_BENEFIT_PAYMENT](../database-tables.md#cl_benefit_payment)).
     - If `RowsAffected = 0`: add error `#PAYDEL#` ([BR-010](../business-rules.md#br-010-benefit-payment-delete-must-affect-a-row)) and return `False`.
     - Otherwise: record `StopStatus.Deleted`.
4. `ReturnTask()` composes a human-readable task description from the `CallingApplication`, `CallingFunction`, and `StopStatus` enums for downstream task creation.*

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([ProcessBenefitPayment called]) --> Retrieve["Retrieve active benefit<br>schedules"]
	Retrieve --> ForEach["For each schedule row:<br>retrieve benefit payment"]
	ForEach --> Check{hasReleasedScheduledPayment?}
	Check -->|Yes| UpdateSched[Update schedule<br>RemainingPaymentCount = 1]
	Check -->|No| DeletePayment[Delete benefit payment row]
	UpdateSched --> RowsA{RowsAffected = 0?}
	DeletePayment --> RowsB{RowsAffected = 0?}
	RowsA -->|Yes| ErrUpd([Error #PAYUPD#<br>return False])
	RowsA -->|No| Released([StopStatus.Released])
	RowsB -->|Yes| ErrDel([Error #PAYDEL#<br>return False])
	RowsB -->|No| Deleted([StopStatus.Deleted])
```

## Failure and edge-case behavior
- A zero-row update raises `#PAYUPD#` and returns `False` without further processing.
- A zero-row delete raises `#PAYDEL#` and returns `False` without further processing.
- The near-identical `clsBenefitSchedule` class (excluded from the compiled build) duplicates this logic using [SQL-016](../sql/SQL-016.md), [SQL-017](../sql/SQL-017.md), [SQL-041](../sql/SQL-041.md), [SQL-042](../sql/SQL-042.md), [SQL-056](../sql/SQL-056.md), and [SQL-057](../sql/SQL-057.md).*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- SAIF.Business.Claim/clsActiveBenefitSchedule.vb
